describe 'StreamingPacket.coffee', ->
  uid=0
  sid=0
  ch0array = null
  ch1array = null
  buffer = null
  target = null
  buffer_view = null
  uint8array = null

  beforeEach ->
    uid = 100
    sid = 200
    ch0array = [1.2, 2.3, 3.4, 4.5, 5.0]
    ch1array = [6.0, 6.1, 6.2, 6.3, 6.4]
    buffer = [new Float32Array(ch0array), new Float32Array(ch1array)]
    target = new StreamingPacket()
    target.create_empty_packet(5, 2)
    buffer_view = target.to_array_buffer(uid, sid, buffer)
    uint8array = new Uint8Array(buffer_view)

  describe 'StreamingPacket class ', ->
    it 'can convert Float32Array to ArrayBuffer', ->
      expect(target.get_uid()).toEqual(uid)
      expect(target.get_sid()).toEqual(sid)
      expect(target.get_pcmbuff_len()).toEqual(5)
      expect(target.get_channel_count()).toEqual(2)

    it 'can convert ArrayBuffer to Float32Array', ->
      target2 = new StreamingPacket()
      target2.from_arraybuffer(buffer_view)
      expect(target2.get_uid()).toEqual(uid)
      expect(target2.get_sid()).toEqual(sid)
      expect(target2.get_pcmbuff_len()).toEqual(5)
      expect(target2.get_channel_count()).toEqual(2)
      expect(target2.pcm_buff[0]).toBeSameArray(new Float32Array(ch0array))
      expect(target2.pcm_buff[1]).toBeSameArray(new Float32Array(ch1array))
      return

